import type { App } from "vue";
// 引入element-plus的组件
import {
    ElTag,
    ElAffix,
    ElSkeleton,
    ElBreadcrumb,
    ElBreadcrumbItem,
    ElScrollbar,
    ElSubMenu,
    ElButton,
    ElCol,
    ElRow,
    ElSpace,
    ElDivider,
    ElCard,
    ElDropdown,
    ElDialog,
    ElMenu,
    ElMenuItem,
    ElDropdownItem,
    ElDropdownMenu,
    ElIcon,
    ElInput,
    ElDatePicker,
    ElForm,
    ElFormItem,
    ElLoading,
    ElPopover,
    ElPopper,
    ElTooltip,
    ElDrawer,
    ElPagination,
    ElAlert,
    ElRadio,
    ElRadioButton,
    ElRadioGroup,
    ElDescriptions,
    ElDescriptionsItem,
    ElBacktop,
    ElSwitch,
    ElBadge,
    ElTabs,
    ElTabPane,
    ElAvatar,
    ElEmpty,
    ElCollapse,
    ElCollapseItem,
    ElInfiniteScroll
} from 'element-plus'

// 声明组件名，用来接收引入的element-plus，两者需要一一对应，使用起来才能像直接使用element-plus组件一样
const components:any[] = [
    ElTag,
    ElAffix,
    ElSkeleton,
    ElBreadcrumb,
    ElBreadcrumbItem,
    ElScrollbar,
    ElSubMenu,
    ElButton,
    ElCol,
    ElRow,
    ElSpace,
    ElDivider,
    ElCard,
    ElDropdown,
    ElDialog,
    ElMenu,
    ElMenuItem,
    ElDropdownItem,
    ElDropdownMenu,
    ElIcon,
    ElInput,
    ElDatePicker,
    ElForm,
    ElFormItem,
    ElPopover,
    ElPopper,
    ElTooltip,
    ElDrawer,
    ElPagination,
    ElAlert,
    ElRadio,
    ElRadioButton,
    ElRadioGroup,
    ElDescriptions,
    ElDescriptionsItem,
    ElBacktop,
    ElSwitch,
    ElBadge,
    ElTabs,
    ElTabPane,
    ElAvatar,
    ElEmpty,
    ElCollapse,
    ElCollapseItem
]
const plugins = [ElLoading, ElInfiniteScroll]
// 引入element-plus图标
import {
  Aim,
  AlarmClock,
  ArrowDownBold,
  ArrowDown,
  ArrowLeftBold,
  ArrowLeft,
  ArrowRightBold,
  ArrowRight,
  ArrowUpBold,
  ArrowUp,
  Avatar,
  Back,
  BellFilled,
  Bell,
  Bottom,
  BrushFilled,
  Brush,
  Calendar,
  CaretBottom,
  CaretLeft,
  CaretRight,
  CaretTop,
  ChatDotRound,
  ChatDotSquare,
  ChatLineRound,
  ChatLineSquare,
  Check,
  CircleCheckFilled,
  CircleCheck,
  CircleCloseFilled,
  CircleClose,
  CirclePlusFilled,
  CirclePlus,
  Clock,
  CloseBold,
  Close,
  Comment,
  Connection,
  CopyDocument,
  Crop,
  DArrowLeft,
  DArrowRight,
  DCaret,
  DeleteFilled,
  Delete,
  Download,
  Edit,
  Expand,
  Filter,
  Fold,
  FullScreen,
  Histogram,
  HomeFilled,
  InfoFilled,
  Iphone,
  Link,
  Loading,
  Lock,
  Message,
  Minus,
  Monitor,
  Moon,
  MoreFilled,
  More,
  Operation,
  Opportunity,
  PictureFilled,
  PictureRounded,
  Picture,
  PieChart,
  Plus,
  Position,
  QuestionFilled,
  Rank,
  RefreshLeft,
  RefreshRight,
  Refresh,
  RemoveFilled,
  Remove,
  Right,
  Search,
  Select,
  SemiSelect,
  Setting,
  Sort,
  StarFilled,
  Star,
  SuccessFilled,
  Sunny,
  SwitchButton,
  Switch,
  Tools,
  Top,
  Unlock,
  UploadFilled,
  Upload,
  UserFilled,
  User,
  WarningFilled,
  Warning,
  ZoomIn,
  ZoomOut,
} from "@element-plus/icons-vue";
// 声明图标组件名
export const iconComponents = [
  Aim,
  AlarmClock,
  ArrowDownBold,
  ArrowDown,
  ArrowLeftBold,
  ArrowLeft,
  ArrowRightBold,
  ArrowRight,
  ArrowUpBold,
  ArrowUp,
  Avatar,
  Back,
  BellFilled,
  Bell,
  Bottom,
  BrushFilled,
  Brush,
  Calendar,
  CaretBottom,
  CaretLeft,
  CaretRight,
  CaretTop,
  ChatDotRound,
  ChatDotSquare,
  ChatLineRound,
  ChatLineSquare,
  Check,
  CircleCheckFilled,
  CircleCheck,
  CircleCloseFilled,
  CircleClose,
  CirclePlusFilled,
  CirclePlus,
  Clock,
  CloseBold,
  Close,
  Comment,
  Connection,
  CopyDocument,
  Crop,
  DArrowLeft,
  DArrowRight,
  DCaret,
  DeleteFilled,
  Delete,
  Download,
  Edit,
  Expand,
  Filter,
  Fold,
  FullScreen,
  Histogram,
  HomeFilled,
  InfoFilled,
  Iphone,
  Link,
  Loading,
  Lock,
  Message,
  Minus,
  Monitor,
  Moon,
  MoreFilled,
  More,
  Operation,
  Opportunity,
  PictureFilled,
  PictureRounded,
  Picture,
  PieChart,
  Plus,
  Position,
  QuestionFilled,
  Rank,
  RefreshLeft,
  RefreshRight,
  Refresh,
  RemoveFilled,
  Remove,
  Right,
  Search,
  Select,
  SemiSelect,
  Setting,
  Sort,
  StarFilled,
  Star,
  SuccessFilled,
  Sunny,
  SwitchButton,
  Switch,
  Tools,
  Top,
  Unlock,
  UploadFilled,
  Upload,
  UserFilled,
  User,
  WarningFilled,
  Warning,
  ZoomIn,
  ZoomOut,
];

export function useElementPlus(app: App) {
    // 注册组件
    components.forEach((component: any) => {
        app.component(component.name, component)
    })
    // 注册指令
    plugins.forEach((plugin) => {
        app.use(plugin)
    })
    // 注册图标
    iconComponents.forEach((component: any) => {
        app.component(component.name, component);
    });
}